package win.larryzeal.thymeleaf.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import win.larryzeal.thymeleaf.entity.User;

/**
 * Created by 张少昆 on 2018/3/15.
 */
@Controller
public class RegController {

    @ModelAttribute( "user" )
    public User user(){
        User user = new User();
        return user;
    }

    @GetMapping( "/reg" )
    public String regPage(){
        return "reg";
    }

    @PostMapping( "/reg" )
    @ResponseBody
    public User reg(@ModelAttribute( "user" ) User user){
        System.out.println(user);
        return user;
    }
}
